class Solution
{
public:
    bool IsPopOrder(vector<int> pushV, vector<int> popV)
    {
        stack<int> data;
        int j = 0;
        for (int i = 0; i < pushV.size(); i++)
        {
            data.push(pushV[i]);
            while (data.size() > 0 && popV[j] == data.top())
            {
                data.pop();
                j++;
            }
        }
        return data.empty();
    }
};